FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git ca-certificates tzdata

WORKDIR /app
ENV GOPROXY=https://goproxy.cn,direct
# 拷贝go.mod go.sum到代码目录
COPY go.mod go.sum ./
# 加载依赖
RUN go mod download
# 将代码目录所以内容拷贝到当前目录
COPY . .
# go build 编译
# -o kubernate-server 编译完放到kubernate-server目录
# . 表示编译的源代码路径为「当前目录」
RUN go build -o kubernate-server .

FROM alpine:latest

WORKDIR /app
# 从上面的构建/app/kubernate-server里面所有内容拷贝到当前路径
COPY --from=builder /app/kubernate-server .
# 从上面的构建/app/conf里面所有内容拷贝到当前路径conf 拷贝配置相关内容
COPY --from=builder /app/conf/ ./conf/

RUN chown -R root:root /app
RUN chmod +x kubernate-server

EXPOSE 8082
CMD ["./kubernate-server"]
